package com.wiseman.writing;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.umeng.analytics.MobclickAgent;
import com.umeng.fb.FeedbackAgent;
import com.umeng.update.UmengUpdateAgent;

public class MainMenuActivity extends Activity implements OnClickListener {

	FeedbackAgent agent;
	Context mContext;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.mainmenu);

		Button bt = (Button) findViewById(R.id.btSearch);
		bt.setOnClickListener(this);

		bt = (Button) findViewById(R.id.btStudy);
		bt.setOnClickListener(this);

		bt = (Button) findViewById(R.id.btFeekback);
		bt.setOnClickListener(this);

		// bt = (Button) findViewById(R.id.btHistory);
		// bt.setOnClickListener(this);

		bt = (Button) findViewById(R.id.btCheckUpdate);
		bt.setOnClickListener(this);

		bt = (Button) findViewById(R.id.btAbout);
		bt.setOnClickListener(this);

		agent = new FeedbackAgent(this);
		// to sync the default conversation. If there is new reply, there
		// will be notification in the status bar. If you do not want
		// notification, you can use
		// agent.getDefaultConversation().sync(listener);
		// instead.
		agent.sync();
		mContext = this;

		// UmengUpdateAgent.update(this);
	}

	@Override
	protected void onResume() {
		super.onResume();
		MobclickAgent.onResume(this);
	}

	@Override
	protected void onPause() {
		super.onPause();
		MobclickAgent.onResume(this);
	}

	@Override
	public void onClick(View v) {

		int id = v.getId();
		Intent intent = new Intent();

		switch (id) {
		case R.id.btStudy:
			intent.setClass(this, StudyTabs.class);
			startActivity(intent);
			break;
		case R.id.btSearch:
			intent.setClass(this, SearchActivity.class);
			startActivity(intent);
			break;
		case R.id.btFeekback:
			MobclickAgent.onEvent(this, "wc_feedback");
			agent.startFeedbackActivity();
			break;
		/*
		 * case R.id.btHistory: MobclickAgent.onEvent(this, "wc_history");
		 * intent.setClass(this, HistoryActivity.class); startActivity(intent);
		 * break;
		 */
		case R.id.btCheckUpdate:
			// DetailsIntent(this);
			// share();
			UmengUpdateAgent.update(this);
			// intent.setClass(this, About.class);
			// startActivity(intent);
			break;
		case R.id.btAbout:
			startActivity(new Intent().setClass(this, About.class));
			break;
		default:
			break;
		}
	}


}
